
<!DOCTYPE html>
<html lang="en-us">
	
<include file="Index/head" />  
<body class="desktop-detected pace-done smart-style-4">

	<!-- #HEADER -->
	<include file="Index/header" />

	
	<!-- END HEADER -->

	<!-- #NAVIGATION -->
	<!-- Left panel : Navigation area -->
	<!-- Note: This width of the aside area can be adjusted through LESS/SASS variables -->
	<!-- Left panel : Navigation area -->
	<!-- Note: This width of the aside area can be adjusted through LESS variables -->
		
	<!-- END NAVIGATION -->
	<!-- END NAVIGATION -->
	<include file="Index/navigation" />
                
	<!-- #MAIN PANEL -->
	<div id="main" role="main">

		<!-- RIBBON -->
		<div id="ribbon">

			<!-- breadcrumb -->
			<ol class="breadcrumb">
				<li>{$module_name}</li>				
			</ol>
			<!-- end breadcrumb -->
			</div>
			<!-- END RIBBON -->

			<!-- #MAIN CONTENT -->

				
			<!-- col -->
            <div id="content">
                <div class="row">
                    <div class="col-xs-12 col-sm-7 col-md-7 col-lg-4">
                        <h1 class="page-title txt-color-blueDark">

                            <!-- PAGE HEADER -->
                            <i class="fa-fw fa fa-home"></i> 
                                {$first_title}
                            <span>>  
                                {$second_title}
                            </span>
                        </h1>
                    </div>
                </div>
                                    
                <!-- widget grid -->
				<section id="widget-grid" class="">
				
					<!-- row -->
					<div class="row">
				
						<!-- NEW WIDGET START -->
						<article class="col-xs-12 col-sm-12 col-md-12 col-lg-12 sortable-grid ui-sortable">
				
							<!-- Widget ID (each widget will need unique ID)-->
							<div class="jarviswidget" id="wid-id-0" data-widget-editbutton="false" data-widget-togglebutton="false" data-widget-deletebutton="false" data-widget-sortable="false">
								<!-- widget options:
								usage: <div class="jarviswidget" id="wid-id-0" data-widget-editbutton="false">
				
								data-widget-colorbutton="false"
								data-widget-editbutton="false"
								data-widget-togglebutton="false"
								data-widget-deletebutton="false"
								data-widget-fullscreenbutton="false"
								data-widget-custombutton="false"
								data-widget-collapsed="true"
								data-widget-sortable="false"
				
								-->
								<header role="heading">
									<h2>主题："{$subject}"&nbsp;的回复记录</h2>	
								</header>
				
								<!-- widget div-->
								<div role="content">
				
									<!-- widget edit box -->
									<div class="jarviswidget-editbox">
										<!-- This area used as dropdown edit box -->
				
									</div>
									<!-- end widget edit box -->
				
									<!-- widget content -->
									<div class="widget-body no-padding">
				
										<table id="dt_basic" class="table table-striped table-bordered table-hover dataTable no-footer" width="100%" role="grid" aria-describedby="dt_basic_info" style="width: 100%;">
											<thead>			                
												<tr role="row">
												<th data-hide="phone" style="width: 30px;">编号</th>
												<th data-class="expand">用户昵称</th>
												<th data-class="expand">帖子内容</th>
												<th data-hide="phone">回复类型</th>
												<!--<th data-hide="phone,tablet">评论图片</th>-->
												<th data-hide="phone,tablet">楼层</th>
												<th data-hide="phone,tablet">发表时间</th>
												<th data-hide="phone,tablet">回复</th>
												<th data-hide="phone,tablet">点赞</th>
												<th data-hide="phone,tablet">举报</th>
												<th data-hide="phone,tablet">操作</th>
												</tr>
											</thead>
											<tbody>                                          
                                                <volist name="results" id="vo">
                                                    <tr>
                                                        <td>{$vo.pid}</td>
                                                        <td>{$vo.user}</td>
                                                        <td>{$vo.message}</td>
                                                        <td>{$vo.reply_type}</td>
                                                        <td>{$vo.floor}</td>
                                                        <td>{$vo.ctime|date="Y-m-d H:i:s",###}</td>
                                                        <td><a href="{:U('Forum/Post/comment_record',array('pid'=>$vo['pid']))}" target="_blank">{$vo.replies}</a></td>
                                                        <td><a href="{:U('Forum/Post/comment_like_record',array('pid'=>$vo['pid']))}" target="_blank">{$vo.liketimes}</a></td>
                                                        <td><a href="{:U('Forum/Post/tipoff_record',array('pid'=>$vo['pid']))}" target="_blank">{$vo.tipoff_record}</a></td>
                                                        <td>
                                                        	<div class="btn-group" role="group">
                                                        		<a class="btn btn-xs btn-default" title="编辑" href="{:U('Forum/Post/modify',array('pid'=>$vo['pid']))}"><i class="fa fa-pencil"></i></a>
                                                        		<button class="btn btn-xs btn-default add_forum" title="回帖" data-tid="{$vo.tid}" data-fid="{$vo.fid}" data-subject="{$vo.subject}" data-pid="{$vo.pid}" data-message="{$vo.message}"><i class="fa fa-plus text-primary"></i></button>
                                                        		<if condition="$vo.invisible eq 1" >
            														<a href="javascript:posts_invisible_update({$vo.pid},{$vo.invisible})" class="btn btn-xs btn-default" title="可见">
            															<i class="fa fa-eye-slash text-danger"></i></a>
            													<else />
            														<a href="javascript:posts_invisible_update({$vo.pid},{$vo.invisible})" class="btn btn-xs btn-default" title="隐藏">
            														<i class="fa fa-eye text-success"></i></a>
        														</if>
                                                        	</div>
                                                        </td>
                                                    </tr>
                                                </volist>
                                            </tbody>
                                        </table>

									</div>
									<!-- end widget content -->
				
								</div>
								<!-- end widget div -->
				
							</div>
							<!-- end widget -->
				
							<!-- Widget ID (each widget will need unique ID)-->
							
							<!-- end widget -->
				
							<!-- Widget ID (each widget will need unique ID)-->
							
							<!-- end widget -->
				
							<!-- Widget ID (each widget will need unique ID)-->
							
							<!-- end widget -->
				
						</article>
						<!-- WIDGET END -->
				
					</div>
				
					<!-- end row -->
				
					<!-- end row -->
				
				</section>
				<!-- end widget grid -->

			</div>
				<!-- end col -->
				

			<!-- end row -->
			
			<!-- END #MAIN CONTENT -->

		</div>
                
		<!-- END #MAIN PANEL -->
<!-- Modal -->
<div id="addtab" title="回帖">
    <form id="addtab_form" method="post" action="{:U('Forum/Post/replies')}">
    	<legend><span class="text-success">帖子：</span><span id="form_message"></span></legend>
    	<input type="hidden" name="fid" id="forum_id" />
    	<input type="hidden" name="tid" id="thread_id" />
		<input type="hidden" name="reply_pid" id="post_id" />
		<input type="hidden" name="userid" id="user_id" />
		<input type="hidden" name="subject" id="thread_subject" />
		<input type="hidden" name="images" id="file_images" />
        <fieldset>
        	<div class="form-group">
                <label>回帖用户</label>
                <input type="text" name="nickname" class="form-control" id="user-typeahead" data-provide="typeahead" placeholder="" autocomplete="off"/>
            </div>
            <div class="form-group">
                <label>回复内容</label>
                <textarea class="form-control" placeholder="内容" rows="5" name="message"></textarea> 
            </div>
            <div class="form-group">
                <label>图片</label>
                <div class="dropzone needsclick" id="UploadImage">
					<div class="dz-message needsclick">
    					<h3>拖拽文件到虚线框内上传或点击上传文件</h3>
    					<span class="text-danger">(支持多文件同时上传，最大上传文件大小：5 MB)</span>
  					</div>
				</div>
            </div>            
        </fieldset>
    </form>
</div>
<!-- Modal END-->		

		<!-- #PAGE FOOTER -->
		
		<!-- END FOOTER -->
<include file="Index/footer" />
<!-- JARVIS WIDGETS -->
<script src="{$resource_basic}js/smartwidgets/jarvis.widget.min.js"></script>

<!-- typeahead -->
<script src="{$resource_basic}js/plugin/typeahead/jquery.mockjax.js"></script>		
<script src="{$resource_basic}js/plugin/typeahead/bootstrap-typeahead.min.js"></script>			

<!-- Demo purpose only -->
<!--<script src="{$resource_basic}js/demo.min.js"></script>-->

<!-- MAIN APP JS FILE -->
<!--<script src="{$resource_basic}js/app.min.js"></script>-->
                
<script src="{$resource_basic}js/plugin/datatables/jquery.dataTables.min.js"></script>
<script src="{$resource_basic}js/plugin/datatables/dataTables.colVis.min.js"></script>
<script src="{$resource_basic}js/plugin/datatables/dataTables.tableTools.min.js"></script>
<script src="{$resource_basic}js/plugin/datatables/dataTables.bootstrap.min.js"></script>
<script src="{$resource_basic}js/plugin/datatable-responsive/datatables.responsive.min.js"></script>

<!--dropzone upload file -->
<script src="{$resource_basic}js/dropzone/dropzone.min.js"></script>
<script type="text/javascript">
   $(document).ready(function () {

        Dropzone.options.myAwesomeDropzone = false;
        Dropzone.autoDiscover = false;

        function delstr(str) { 
        	var regex = new RegExp(str.replace('\,','\\\,')); 
        	var ipt = document.getElementById('file_images'); 
        	ipt.value = ipt.value.replace(regex,''); 
        }

        $("div#UploadImage").dropzone({
            url: "{:U('Forum/Thread/upload')}",
            //method: 'post',
            maxFilesize: 20,
            maxFiles: 3,
            addRemoveLinks: true,
            //paramName: "file",//设置传输文件名称参数. 默认是 file
            //uploadMultiple:true,
            //autoProcessQueue:true,//自动上传
            acceptedFiles: "image/jpg, image/jpeg, image/png, image/gif, image/bmp",
            dictFileTooBig: "文件大小超过限制",
            dictRemoveFile:"删除文件",
            maxfilesexceeded: function(file) {
        		alert('仅能上传3张图片');
        		var name = file.name;
                var ref;
                return (ref = file.previewElement) != null ? ref.parentNode.removeChild(file.previewElement) : void 0;
    		},
            init: function() {
            	this.on("success", function(file) {
                	console.log("File " + file.name + "uploaded");
            	});
            	this.on("removedfile", function(file) {
                	console.log("File " + file.name + "removed");
            	});
        	},
        	sending: function(file, xhr, formData) {
      			formData.append("filesize", file.size);
    		},
    		success: function (file, response, e) {
    			file.previewElement.setAttribute("data-id",response);
    			$("#file_images").val($("#file_images").val()+response+",");//input#file_images追加图片id
      			//console.log(response);
    		},
            removedfile: function (file) {
                var name = file.name;
                var ref;
                var id=file.previewElement.getAttribute("data-id");
                delstr(id+",");//input#file_images删除图片id
                return (ref = file.previewElement) != null ? ref.parentNode.removeChild(file.previewElement) : void 0;
            },
            
        });
	});
</script>
<script type="text/javascript">
		
// DO NOT REMOVE : GLOBAL FUNCTIONS!
		
$(document).ready(function() {
			
	pageSetUp();
				
	/* BASIC ;*/
	var responsiveHelper_dt_basic = undefined;
	var responsiveHelper_datatable_fixed_column = undefined;
	var responsiveHelper_datatable_col_reorder = undefined;
	var responsiveHelper_datatable_tabletools = undefined;
				
	var breakpointDefinition = {
		tablet : 1024,
		phone : 480
	};
	
	$('#dt_basic').dataTable({
		"sDom": "<'dt-toolbar'<'col-xs-12 col-sm-6'f><'col-sm-6 col-xs-12 hidden-xs'l>r>"+
				"t"+
				"<'dt-toolbar-footer'<'col-sm-6 col-xs-12 hidden-xs'i><'col-xs-12 col-sm-6'p>>",
		stateSave: true,		
		"autoWidth" : true,
		"sPaginationType": "full_numbers",
		"aLengthMenu": [[15, 25, 50, 100, -1], [15, 25, 50, 100, "All"]],
		"oLanguage": {
            "sSearch": '<span class="input-group-addon"><i class="glyphicon glyphicon-search"></i></span>',
            "sProcessing": "处理中...",
        	"sLengthMenu": "每页显示条数 _MENU_ ",
        	"sZeroRecords": "没有匹配结果",
        	"sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
        	"sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",
        	"sInfoFiltered": "(由 _MAX_ 项结果过滤)",
        	"sInfoPostFix": "",
        	//"sSearch": "搜索: ",
        	"sUrl": "",
        	"sEmptyTable": "表中数据为空",
        	"sLoadingRecords": "载入中...",
        	"sInfoThousands": ",",
        	"oPaginate": {
            	"sFirst": "首页",
            	"sPrevious": "上页",
            	"sNext": "下页",
            	"sLast": "末页"
        	},
        	"oAria": {
            	"sSortAscending": ": 以升序排列此列",
            	"sSortDescending": ": 以降序排列此列"
        	}
        },
		"preDrawCallback" : function() {
			// Initialize the responsive datatables helper once.
			if (!responsiveHelper_dt_basic) {
				responsiveHelper_dt_basic = new ResponsiveDatatablesHelper($('#dt_basic'), breakpointDefinition);
			}
		},
		"rowCallback" : function(nRow) {
			responsiveHelper_dt_basic.createExpandIcon(nRow);
		},
		"drawCallback" : function(oSettings) {
			responsiveHelper_dt_basic.respond();
		}
	});
	
	/* END BASIC */		
});


$(function(){
    
    //dialog              
    var dialog = $("#addtab").dialog({
		autoOpen : false,
		width : 600,
		resizable : false,
		modal : true,
		buttons : [{
			html : "<i class='fa fa-times'></i>&nbsp; 取消",
			"class" : "btn btn-default",
			click : function() {
				$(this).dialog("close");		
			}
		}, {
		
			html : "<i class='fa fa-plus'></i>&nbsp; 提交",
			"class" : "btn btn-primary",
			click : function() {
				$("#addtab_form").submit();
				$(this).dialog("close");
			}
		}]
	});
        
    $(".add_forum").click(function() {
		dialog.dialog("open");
		$(".ui-dialog #form_message").html($(this).attr('data-message'));//帖子内容
    	$("#forum_id").val($(this).attr('data-fid'));//圈子id
    	$("#thread_id").val($(this).attr('data-tid'));//主题id
    	$("#post_id").val($(this).attr('data-pid'));//帖子id
    	$("#thread_subject").val($(this).attr('data-subject'));//主题id
	});

	//动态加载用户
	function displayResult(item) {
		$("#user_id").val(item.value);//用户id
        //$('.alert').show().html('You selected <strong>' + item.value + '</strong>: <strong>' + item.text + '</strong>');
    }
    $('#user-typeahead').typeahead({
        ajax: {
            url: "{:U('Forum/Common/get_private_user')}",
            method: 'post',
            triggerLength: 1
        },
        displayField: 'nickname',
        valueField: 'userid',
        onSelect: displayResult
    });

});

function posts_invisible_update(pid,invisible){
	var pid = pid;
	var invisible = invisible;
	var now_url = window.location.href;
	var url = "{:U('Forum/Post/posts_invisible_update')}";
	$.ajax({
		type:'post',
		url:url,
		data:{pid:pid,invisible:invisible},
		dataType:'json',
		success:function(data){
			if(data==1){
				window.location.href = now_url;
			}
		}
	});
}
</script>	
</body>
</html>